Websydian v6.1 online documentationOnline documentation - Websydian v6.5

Problem - TransacXML XML modeling simple elements with attributes

Product Websydian TransacXML
Version v5.5 to v6.0
Resolved in v6.1
Platform Windows, and Java
Category TransacXML
Question We would like to be able to process xml documents where simple element fields has an attribute.

e.g. <amount currency="USD">10</amount>

How do I model this using TransacXML

Answer Websydian TransacXML does not support the modelling of xml documents with simple elements holding one or more attributes.

This will be supported in future releases, for current releases check the workaround below.

Workaround The workaround requires you to call a number of DOM functions located in the WSYDOM library.

For the entity scoping the element field with the attribute add a field to the fields functions making sure that this field does NOT inherit from either ElementField or AttributeField. Then add a has field triple to the entity. The newly created field has to have the implementation name of the attribute and will hold the value of the attribute.

 

Altering the SingleFetch function

In the Edit Point "End find child element with name" of the SingleFetch being performed to retrieve the values, add code to retrieve the attribute.
 

if local<found> == <Found.*True> && Local<TempString> == currency
  Call WSYDOM/DomInterfaces.Element.getAttribute
    // Input<ObjectStoreReference>
    // Local<ChildNode>
    // The name of the attribute
 

Set the data field to hold the value = output from the getAttribute

 

Altering the UpdateRow and InsertRow function
For InsertRow and UpdateRow add the following code to the Edit Point "End find child element with name".

 

if local<found> == Found.*True> && Local<TempString> == currency
  call WSYDOM/DomInterfaces.Element.setAttribute
  // Input<ObjectStoreReference>
  // Local<ChildNode>
  // AttributeName
  // AttributeValue
 

Where AttrbuteName is the name of the attribute to add "currency" and the AttributeValue is the value of the currency field.